//
//  WZTableBarController.swift
//  weibo
//
//  Created by mac on 16/2/24.
//  Copyright © 2016年 mac. All rights reserved.
//

import UIKit

class WZTableBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()

      
        let tabbar = WZTabBar()
        
        setValue(tabbar, forKey: "tabBar")
          addChildVC()
        
//        为中间的按钮添加碘剂方法，也可以在tabbar里面设置但是在控制器里面设置显得更好
        tabbar.composeButton.addTarget(self, action: "composeButtonClick", forControlEvents: UIControlEvents.TouchUpInside)
        
    }
    func composeButtonClick(){
        
        let publishVc = WZPublishViewController()
        presentViewController(UINavigationController(rootViewController: publishVc), animated: true) { () -> Void in
            
        }
        
    }

    func addChildVC (){
        
        creatChildVC(WZHomeController(), iconName: "tabbar_home", title: "首页")
        
        
        creatChildVC(WZMessageController(), iconName: "tabbar_message_center", title: "消息")
        
         creatChildVC(WZFindController(), iconName: "tabbar_discover", title: "发现")
        creatChildVC(WZSettingController(), iconName: "tabbar_profile", title: "设置")
        
    }
    
    
    
    func creatChildVC (childVC: UIViewController,iconName: String,title: String){
        

        //设置文字
        childVC.title = title
        //设置图片
        childVC.tabBarItem.image = UIImage(named: iconName)
        //字符串进行拼接
        childVC.tabBarItem.selectedImage = UIImage(named: "\(iconName)_highlighted")
        
        //如果不改变tintColor的颜色的画,系统默认渲染蓝色
//        UITabBar.appearance().tintColor = UIColor.orangeColor()
        
        addChildViewController(UINavigationController(rootViewController: childVC))
        
    }
   

  
}
